// scaup - Scala up!
// (c) 2008-2010, Normen Müller, normen.mueller@gmail.com  
// $Id: Components.scala 81 2010-05-13 12:40:40Z normen.mueller $
package scaup.dot

/** 
 *  @author <a href="mailto:normen.mueller@googlemail.com">Normen M&#xFC;ller</a>
 *  @version 0.0.5
 */
abstract class Component

/** 
 *  @author <a href="mailto:normen.mueller@googlemail.com">Normen M&#xFC;ller</a>
 *  @version 0.0.5
 */
sealed trait Statement extends Component

/** 
 *  @author <a href="mailto:normen.mueller@googlemail.com">Normen M&#xFC;ller</a>
 *  @version 0.0.5
 */
sealed trait EdgeComponent extends Statement

/** 
 *  @author <a href="mailto:normen.mueller@googlemail.com">Normen M&#xFC;ller</a>
 *  @version 0.0.5
 */
sealed trait Attributed extends Component {
  val attributes: Seq[Attr]
}

/** 
 *  @author <a href="mailto:normen.mueller@googlemail.com">Normen M&#xFC;ller</a>
 *  @version 0.0.5
 */
sealed abstract class AbstractGraph extends Component {
  /** Optional graph id
   */
  val id: Option[String]
  
  /** The graph statements
   */
  val statements: Seq[Statement]
}

/** 
 *  @author <a href="mailto:normen.mueller@googlemail.com">Normen M&#xFC;ller</a>
 *  @version 0.0.5
 */
case class Graph(strict: Boolean, digraph: Boolean, id: Option[String], statements: Statement*) extends AbstractGraph

/** 
 *  @author <a href="mailto:normen.mueller@googlemail.com">Normen M&#xFC;ller</a>
 *  @version 0.0.5
 */
case class Subgraph(id: Option[String], statements: Statement*) extends AbstractGraph with EdgeComponent

/** 
 *  @author <a href="mailto:normen.mueller@googlemail.com">Normen M&#xFC;ller</a>
 *  @version 0.0.5
 */
case class Node(id: String, attributes: Attr*) extends EdgeComponent with Attributed

/** 
 *  @author <a href="mailto:normen.mueller@googlemail.com">Normen M&#xFC;ller</a>
 *  @version 0.0.5
 */
case class Edge(attributes: Seq[Attr], left: EdgeComponent, right: EdgeComponent) extends Statement with Attributed

/** 
 *  @author <a href="mailto:normen.mueller@googlemail.com">Normen M&#xFC;ller</a>
 *  @version 0.0.5
 */
case class Attrs(kind: String, attributes: Attr*) extends Statement with Attributed

/** 
 *  @author <a href="mailto:normen.mueller@googlemail.com">Normen M&#xFC;ller</a>
 *  @version 0.0.5
 */
case class Attr(name: String, value: String) extends Component {
//  override def hashCode = name.hashCode
//  override def equals(other: Any): Boolean = other match {
//    case that: Attr => (that canEqual this) && name == that.name
//    case _          => false
//  }
//  def canEqual(other: Any): Boolean = other.isInstanceOf[Attr]
}
